<template>
  <div>
    <el-dialog
      title="编辑标签"
      :visible.sync="dialogVisible"
      width="20%"
    >
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="标签名称">
          <el-input v-model="form.name"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="handleOk">确 定</el-button>
  </span>
    </el-dialog>
  </div>
</template>

<script>
  import {createOrEditTag} from "@/api/set";

  export default {
    name: "edit",
    data() {
      return {
        dialogVisible: false,
        form: {
          id: '',
          name: ''
        }
      }
    },
    methods: {
      show(data) {
        this.form.id = data.id
        this.form.name = data.name
        this.dialogVisible = true
      },
      handleOk() {
        createOrEditTag(this.form).then(res => {
          if (res.status === 200) {
            this.$emit('Ok')
            this.dialogVisible = false
            this.$message.success("编辑成功")
          }
        })
      }
    }
  }
</script>

<style scoped>

</style>
